<template>
	<view>
	  <label style="margin: 20px; display: block;">-{{text}}-</label>
	 <view @click="whole.onClick" id="onClick"></view>
	  </view>
</template>

<script>
	export default {
		data() {
			return {
				text: 'text'
			}
		},
		methods: {
			keyCodeClick(keyCode) {
				this.text = keyCode;
				}
		}
	}
</script>

<script module="whole" lang="renderjs">
    let keyCode;
    export default {
        mounted() {
            //全局监听按键输入
            window.document.onkeydown = function(evt) {
                evt = evt || window.event;
                keyCode = evt.which || evt.keyCode;
                document.getElementById("onClick").click();
            }
        },
        methods: {
            onClick(event, ownerInstance, c) {
                // 调用 service 层的方法
                ownerInstance.callMethod('keyCodeClick', keyCode);
            }

        }
    }
</script>
<style>

</style>
